//
//  UIImage+RWAdditions.h
//  iconstruction-ios
//
//  Created by 81SK on 2022/9/19.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface UIImage (RWAdditions)

/// Base64字符串转图片
+ (UIImage *)rw_imageWithBase64String:(NSString *)base64String;

/// 图片转Base64字符串
+ (NSString *)rw_imageToBase64String:(UIImage *)image;

/// 生成指定尺寸缩略图
/// - Parameters:
///   - image: 原图
///   - asize: 尺寸
+ (UIImage *)rw_thumbnailWithImageWithoutScale:(UIImage *)image size:(CGSize)asize;



/// 截取图片上指定尺寸内容
/// @param bounds 指定尺寸
- (UIImage *)rw_croppedImage:(CGRect)bounds;

/// 截取图片上指定尺寸内容（可以的改变图片方向）
/// @param bounds 指定尺寸
/// @param orientation 照片方向枚举
- (UIImage *)rw_croppedImage:(CGRect)bounds
             WithOrientation:(UIImageOrientation)orientation;

- (UIImage *)rw_resizedImage:(CGSize)newSize
        interpolationQuality:(CGInterpolationQuality)quality;

- (UIImage *)rw_resizedImageWithContentMode:(UIViewContentMode)contentMode
                                     bounds:(CGSize)bounds
                       interpolationQuality:(CGInterpolationQuality)quality;

- (UIImage *)rw_resizedImage:(CGSize)newSize
                transform:(CGAffineTransform)transform
           drawTransposed:(BOOL)transpose
     interpolationQuality:(CGInterpolationQuality)quality;

- (CGAffineTransform)rw_transformForOrientation:(CGSize)newSize;

- (UIImage *)rw_fixOrientation;

- (UIImage *)rw_rotatedByDegrees:(CGFloat)degrees;


/// 截取当前view生成image
/// - Parameter theView: 需要截取的view
+ (UIImage *)rw_croppedImageFromView:(UIView *)theView;

/// 截取当前view生成image
/// - Parameters:
///   - theView: 需要截取的view
///   - opaque: 透明开关，如果图形完全不用透明，设置为YES以优化位图的存储，我们得到的图片背景将会是黑色，使用NO，表示透明，图片背景色正常
+ (UIImage *)rw_croppedImageFromView:(UIView *)theView opaque:(BOOL)opaque;

/// 根据当前图片方向和设备方向来旋转照片
/// - Parameter deviceOrientation: 设备方向
- (UIImage *)rw_changeImageWithOrientation:(UIDeviceOrientation)deviceOrientation;

@end

NS_ASSUME_NONNULL_END
